<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;
class GroupController extends  CommonController  {

    public function indexAction(){
        $model=M();
        $sql="select * from grouplist";
        $groupInfo = $model->query($sql);
        $this->assign('groupInfo',$groupInfo);
        $this->display('index');
    }

    /**
     *编辑系统组
     */
    public function editAction(){
        $id = I('get.id');
        $model=M();
        $sql="select * from grouplist where id = '{$id}'";
        $groupInfo = $model->query($sql);
        $this->assign('groupInfo',$groupInfo);
        $this->display('edit');
    }

    /**
     *更新系统组到数据库
     */
    public function updateAction(){
        $group_name = I('post.group_name');
        $id = I('post.id');
        $model = M();
        $sql = "update grouplist set group_name = '{$group_name}' where id = '{$id}'";
        if($model->execute($sql)){
            $this->success('修改成功',U('Admin/Group/index'),1);
        }
    }

}